package com.ponhu.ea2.vo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;

/**
 * @author luyu
 * @create 2021-10-14 13:53
 */
@Data
@Accessors(chain = true)
@ApiModel(value = "返回物料的详细信息")
public class PhMaterialVo implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "物料ID")
    private Long materialId;

    @ApiModelProperty(value = "物料编码")
    private String materialCode;

    @ApiModelProperty(value = "物料名称")
    private String materialName;

    @ApiModelProperty(value = "一级分类ID")
    private String firstCategoryId;

    @ApiModelProperty(value = "一级分类名称")
    private String firstCategoryName;

    @ApiModelProperty(value = "二级分类ID")
    private String secondCategoryID;

    @ApiModelProperty(value = "二级分类名称")
    private String secondCategoryName;

    @ApiModelProperty(value = "三级分类id")
    private Long thirdCategoryId;

    @ApiModelProperty(value = "三级分类名称")
    private String thirdCategoryName;

    @ApiModelProperty(value = "品牌ID")
    private Long brandId;

    @ApiModelProperty(value = "品牌中文名称")
    private String brandCnName;

    @ApiModelProperty(value = "品牌英文名称")
    private String brandEnName;

    @ApiModelProperty(value = "系列ID")
    private Long seriesId;

    @ApiModelProperty(value = "系列名称")
    private String seriesName;

    @ApiModelProperty(value = "系列别名")
    private String seriesOtherName;

    @ApiModelProperty(value = "型号ID")
    private Long modelId;

    @ApiModelProperty(value = "型号名称")
    private String modelName;

    @ApiModelProperty(value = "主图")
    private String mainImage;

    @ApiModelProperty("官网售价")
    private BigDecimal officialPrice;

    @ApiModelProperty(value = "官网售价：未知")
    private String officialPriceStr;

    @ApiModelProperty(value = "件")
    private String unit;

    @ApiModelProperty(value = "上市时间")
    private String marketDate;

    @ApiModelProperty(value = "适用人群")
    private String applyCrowd;

    @ApiModelProperty(value = "物料属性和属性值的集合")
    private List<PhPropertyVo> materialPropertyValueList;

    @ApiModelProperty(value = "物料属性集合-编辑使用")
    private List<PhPropertyEditVo> phPropertyVos;

    @ApiModelProperty(value = "创建人")
    private String createdByName;

    @ApiModelProperty(value = "创建时间")
    private LocalDateTime createdTime;

    @ApiModelProperty(value = "物料卖点")
    private String sellingPoint;

    public String getOfficialPriceStr() {
        if (ObjectUtils.isEmpty(officialPrice) || officialPrice.compareTo(BigDecimal.valueOf(0L)) <= 0) {
            return "未知";
        } else {
            return officialPrice.toString();
        }
    }

    public String getSeriesName() {
        return StringUtils.isEmpty(seriesName) ? "未知" : seriesName;
    }

    public String getModelName() {
        return StringUtils.isEmpty(modelName) ? "未知" : modelName;
    }

}
